﻿using IdentityServer4.EntityFramework.Entities;
using Ids4.Api.Models.Dtos.Client;
using Ids4.Api.Models.Vos.Client;

namespace Ids4.Api.Application.Profiles
{
    public class ClientProfile : Profile
    {
        public ClientProfile()
        {
            CreateMap<Client, ClientListVo>(MemberList.None);

            CreateMap<CreateClientDto, Client>(MemberList.None);

            CreateMap<ClientVo, Client>(MemberList.None).ReverseMap();


            CreateMap<ClientGrantType, string>(MemberList.None)
                   .ConstructUsing(src => src.GrantType)
                   .ReverseMap()
                   .ForMember(dest => dest.GrantType, opt => opt.MapFrom(src => src));

            CreateMap<ClientRedirectUri, string>(MemberList.None)
                .ConstructUsing(src => src.RedirectUri)
                .ReverseMap()
                .ForMember(dest => dest.RedirectUri, opt => opt.MapFrom(src => src));

            CreateMap<ClientPostLogoutRedirectUri, string>(MemberList.None)
                .ConstructUsing(src => src.PostLogoutRedirectUri)
                .ReverseMap()
                .ForMember(dest => dest.PostLogoutRedirectUri, opt => opt.MapFrom(src => src));

            CreateMap<ClientScope, string>(MemberList.None)
                .ConstructUsing(src => src.Scope)
                .ReverseMap()
                .ForMember(dest => dest.Scope, opt => opt.MapFrom(src => src));

            CreateMap<ClientIdPRestriction, string>(MemberList.None)
                .ConstructUsing(src => src.Provider)
                .ReverseMap()
                .ForMember(dest => dest.Provider, opt => opt.MapFrom(src => src));

            CreateMap<ClientCorsOrigin, string>(MemberList.None)
                .ConstructUsing(src => src.Origin)
            .ReverseMap()
                .ForMember(dest => dest.Origin, opt => opt.MapFrom(src => src));



            CreateMap<ClientSecret, ClientSecretVo>(MemberList.None);
            CreateMap<CreateClientSecretDto, ClientSecret>(MemberList.None);
            CreateMap<ClientClaim, ClientClaimDto>(MemberList.None);
            CreateMap<ClientProperty, ClientPropertyVo>(MemberList.None);
            CreateMap<CreateClientPropertyDto, ClientProperty>(MemberList.None);
            CreateMap<UpdateClientDto, Client>(MemberList.None);
        }
    }
}
